Skip to content

Fix: PHP error on new install#2385

Merged
limetech merged 1 commit into
unraid:masterfrom
Squidly271:patch-5
Sep 19, 2025
Merged

Fix: PHP error on new install#2385
limetech merged 1 commit into
unraid:masterfrom
Squidly271:patch-5

Conversation

@Squidly271

@Squidly271 Squidly271 commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Resolved a rare issue when saving VM configurations with no entries, preventing errors and ensuring empty configurations are handled correctly.
  • Chores

    • Updated copyright notice to 2025.

@github-actions

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2025.09.19.1414
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2385/webgui-pr-2385.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates

📝 Modified Files:

Click to expand file list
emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2025.09.19.1414, or run:

plugin remove webgui-pr-2025.09.19.1414

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@elibosley

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 19, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Single-file edit updates header year and initializes a temporary string variable before concatenation when writing a cfg file.

Changes

Cohort / File(s) Summary
Libvirt config script tweaks
emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig
Updated copyright year to 2015–2025. Added $tmp = "" initialization before foreach that appends to $tmp when building cfg output; ensures defined variable even when cfg_new is empty.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

In wires and whiskers I softly cheer,
A tidy tweak greets the brand-new year.
An empty string, a safer start—
No ghostly vars to haunt the art.
I twitch my nose, approve the run—
Small hops toward config done. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix: PHP error on new install" accurately and concisely communicates the primary intent of the change — addressing a PHP error encountered on fresh installs by initializing a variable in the libvirtconfig script — and avoids noise or vague wording; it need not name the exact variable or file to be a valid, helpful PR title.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig (4)

38-39: Optional: avoid .= in loop; build once and implode.

Reduces repeated string reallocations and is a bit clearer.

-  foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n";
+  $lines = [];
+  foreach ($cfg_new as $key => $value) { $lines[] = "$key=\"$value\""; }
+  $tmp = implode("\n", $lines) . "\n";

39-39: Add file lock for safer writes.

Prevents concurrent processes from clobbering the cfg during writes.

-  file_put_contents($cfgfile, $tmp);
+  file_put_contents($cfgfile, $tmp, LOCK_EX);

29-34: Use key-aware comparison; array_diff ignores keys.

array_diff() compares values only; duplicate values across different keys can yield a false “no changes” result. Compare assoc diffs both ways or normalize and compare.

-    if (empty(array_diff($cfg_new, $cfg_old))) unset($cfg_new);
+    if (empty(array_diff_assoc($cfg_new, $cfg_old)) && empty(array_diff_assoc($cfg_old, $cfg_new))) {
+      unset($cfg_new);
+    }

14-14: Avoid short open tag.

Replace <? with <?php to remove short_open_tag dependency in varied PHP configs.

-<?
+<?php
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80a7550 and 079e3ba.

📒 Files selected for processing (1)
  • emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Squidly271
PR: unraid/webgui#0
File: :0-0
Timestamp: 2025-05-31T05:10:13.120Z
Learning: Squidly271 prefers not to receive CodeRabbit reviews or feedback while PRs are in draft status. Only provide reviews after PRs are moved out of draft.
🔇 Additional comments (2)
emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig (2)

3-3: Header year update is correct.

Matches current year and is consistent with the file history.


37-37: Good fix: initialize $tmp before concatenation.

Prevents undefined-variable notices on first-run installs when building the cfg content.

@ljm42 ljm42 added the 7.2 label Sep 19, 2025
@limetech limetech merged commit 9b0e51a into unraid:master Sep 19, 2025
2 checks passed
@Squidly271 Squidly271 deleted the patch-5 branch November 5, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants